from a0base.base_llm import logger


class CityFlightServer:
    # 1. 改为 dict，key=城市名，value=航班列表
    CITY_FLIGHT_DATA = {
        "北京": [
            {"flight": "CA4101", "price": 880},  # 北京 → 成都
            {"flight": "CZ3112", "price": 1020}  # 北京 → 广州
        ],
        "上海": [
            {"flight": "MU5401", "price": 760},  # 上海 → 重庆
            {"flight": "HO1111", "price": 690}   # 上海 → 深圳
        ],
        "广州": [
            {"flight": "CZ3441", "price": 580},  # 广州 → 昆明
            {"flight": "CA4588", "price": 720}   # 广州 → 上海
        ],
        "深圳": [
            {"flight": "ZH9981", "price": 630},  # 深圳 → 杭州
            {"flight": "MU2862", "price": 540}   # 深圳 → 南京
        ],
        "杭州": [
            {"flight": "CA1711", "price": 460},  # 杭州 → 北京
            {"flight": "MF8345", "price": 590}   # 杭州 → 厦门
        ]
    }

    async def get_city_flight(self, city: str) -> str:
        logger.info(f"获取航班信息: {city}")
        flights = self.CITY_FLIGHT_DATA.get(city)
        if flights:
            # 2. 直接返回整个航班列表，方便后续拼接或解析
            return f"{city} : {flights}"
        else:
            return f"抱歉，未找到 {city} 的航班信息"